package com.zzty.txj1.controller;

import com.zzty.txj1.entity.BusPoint;
import com.zzty.txj1.service.BusPointService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/busPoint")
public class BusPointController {
    private static final Logger logger = LoggerFactory.getLogger(BusPointController.class);

    @Autowired
    private BusPointService busPointService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map add(BusPoint busPoint) {
        Map<String, String> result = new HashMap<>();
        String resultValue = "false";
        Integer count = busPointService.addBuspoint(busPoint);
        if (count == 1) {
            resultValue = "success";
        }
        result.put("msg", resultValue);
        logger.info("BusPoint--controller ============ add result :" + result);

        return result;
    }

    @RequestMapping("/getAll")
    public List getAll() {
        List<BusPoint> busPoints = busPointService.getAllBuspoint();
        logger.info("BusPoint--controller ============ add busPoints :" + busPoints);
        return busPoints;
    }
}
